﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using EvoSim.RandomNumberGenerators;
using EvoSim.Simulation.Genes;
using System.Collections.ObjectModel;

namespace EvoSim.Simulation.NeuralNets.RMP
{
	public class RMP_Neuron : IDObject
	{
		public RMP_Net Net;
		public string GeneID { get; set; }

		public double Bias;

		public SigmoidFunction SigmoidFunction;

		public double Activation;
		double output;
		public double Output
		{
			get { return output; }
			set { output = value; }
		}
		public List<RMP_Connection> Connections { get; protected set; }

		public RMP_Neuron(RMP_Net net)
		{
			Net = net;
			Connections = new List<RMP_Connection>();
		}

		public virtual void Update()
		{
			Output = SigmoidFunction.Sigmoid(Activation - Bias);
			Activation = 0;

			foreach (var connection in Connections)
				connection.OutputToTarget();
		}

		public void ImprintGene(RMP_NeuronGene gene)
		{
			Name = gene.Name;
			GeneID = gene.ID;

			Bias = gene.Bias.Value;

			SigmoidFunction = gene.SigmoidFunction;
		}
	}
}
